<!-- 课件-->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="课件" prop="courseName">
        <el-input
          v-model="queryParams.courseName"
          placeholder="请输入课件名"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="课件分类" prop="professionId">
        <el-select
          v-model="queryParams.professionId"
          placeholder="课件类型"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in dict.type.sys_course_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="searchTable()"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="emptySearch()"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-col :span="24">
      <el-table :data="tableData" border>
        <el-table-column prop="courseName" label="课件名" align="center">
        </el-table-column>
        <el-table-column prop="courseSecond" label="课件时长" align="center">
          <template slot-scope="scope">
                    {{ formatDuration(scope.row.courseSecond) }} <!-- 使用格式化方法 -->
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" align="center">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="200" align="center">
          <template slot-scope="scope">
            <el-button @click="previewVideo(scope.row)" type="text" size="small"
              >预览</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-col>
    <el-row>
      <el-col>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <PreviewVideo
      ref="previewVideo"
    ></PreviewVideo>
  </div>
</template>
    
    
<script>
import { getCourseList } from "@/api/course/index.js";
import PreviewVideo from "./PreviewVideo";
import {formatDuration} from '@/utils/ruoyi.js'
export default {
  components: {
    PreviewVideo,
  },
  dicts: ["sys_course_type"],
  data() {
    return {
          // 显示搜索条件
      showSearch: true,
      tableData: [],
      total: 1,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        courseName: undefined,
        professionId: undefined,
        courseType:0
      },
     
    };
  },
  computed: {},
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
 
    //获取试卷列表
    getList() {
      getCourseList(this.queryParams).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.tableData = res.rows;
          this.total = res.total;
        }
      });
    },
    //搜索
    searchTable() {
      this.getList();
    },
    //重置搜索框
    emptySearch() {
      this.queryParams.courseName = "";
      this.queryParams.queryParams=undefined;
      this.resetForm("queryForm");
      this.getList();
    },
    openDialog() {
      this.$refs.dialog.show();
    },

    //预览视频
    previewVideo(row) {
      //打开弹窗
      this.$refs.previewVideo.show(row.courseUrl);
    },
   
  },
};
</script>>
    
<style>
.box {
  height: calc(100vh - 120px);
  font-size: 14px;
  line-height: 28px;
}

.title {
  font-size: 18px;
  font-weight: 700;
  padding-bottom: 10px;
  padding-top: 20px;
  margin-bottom: 10px;
  border-bottom: #eee 1px dotted;
}

.tags span {
  margin-right: 10px;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: hwb(210 95% 5%);
}

.bg-purple {
  border: 0px solid cornflowerblue;
  height: 200px;
}

.app-container {
  height: 100%;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 60px;
}
</style>
    